
# make.pl
open IX , "index.txt";
@tmp = <IX>;
$dat = join("" , @tmp);
close IX;

@imgs = qw(
	_data/img/mapchip.bmp
	_data/img/mapchipB.bmp
	_data/img/mapchipC.bmp
	_data/img/mapchipD.bmp
	_data/img/mapchipE.bmp
	_data/img/mapchipF.bmp
	_data/img/mapchipG.bmp
	);

@stages = split(/\[next\]/ , $dat );
for( $i = 0 ; $i < scalar( @stages ) ; $i++ ) {
	if ( -e "stage$i\.txt" ) { unlink "stage$i\.txt";}
	$mapimg = $imgs[ int( ( $i + 1 ) / 10 ) % scalar( @imgs ) ];
	open DB , sprintf(">stage%04d.txt" , $i + 1 );
	$stages[$i] =~s/(\[\/param\])/mapImg=$mapimg\n$1/;
	print DB $stages[$i];
	close DB;
}


$src = 
'[body]
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
0000000000000000000000000000
[param]
';

for ( $i = 0 ; $i <= 100 ; $i++ ) {
	$file = sprintf("edit%04d.txt" , $i );
	if ( !-e $file ) {
		open DB , ">$file";
		binmode DB;
		print DB $src;
		close DB;
	}
}